<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function arr(strs) {
      let obj = {}
      strs.forEach(word => {
        // 将每个字符串分割成数组进行排序，然后再变成字符串
        const key = word.split('').sort().toString()
        // 对每个key都创建一个数组，用来保存key相同的字符串
        if (!(key in obj)) {
          obj[key] = []
        }
        obj[key].push(word)
      })
      return Object.values(obj)
    };
    console.log(arr(["eat", "tea", "tan", "ate", "nat", "bat"],));

  </script>
</body>

</html>